﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DataLayer;

namespace CinemaGUI
{
    public partial class BookingGUI : Form
    {
        static ScreenCastCTRService.ScreenCastServiceClient scsc = new ScreenCastCTRService.ScreenCastServiceClient();
        static MovieCTRService.MovieServiceClient msc = new MovieCTRService.MovieServiceClient();

        public BookingGUI()
        {
            InitializeComponent();
            this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(CheckEnter);

            // OPRETTER SCREENCASTS
            msc.AddMovie("Die Hard", "", "", "", 0.0);
            msc.AddMovie("High School Musical", "", "", "", 0.0);

            foreach(Movie m in msc.getMovies()) {
                scsc.AddScreenCast(new DateTime(), 3, m);
            }
            // OPRETTER SCREENCASTS END

            Console.WriteLine("Hej...");
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string val = (string)listBox1.SelectedItem.ToString();

            listBox2.Items.Clear();

            foreach (ScreenCast sc in scsc.GetScreenCastsForMovie(val)) {
                //listBox2.Items.AddRange(new object[] { /**sc.Movie.Title + "\t\tPris: " + (sc.Price + sc.Movie.Price) + "\t\tSal: " + "0"*/ });
                listBox2.Items.Add(sc);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {

            SeatGUI seatGUI = new SeatGUI((ScreenCast)listBox2.SelectedItem);
            seatGUI.Show();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void CheckEnter(object sender, System.Windows.Forms.KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)13)
            {
                listBox1.Items.Clear();

                msc.searchIMDBMovies(textBox1.Text);

                foreach (Movie m in msc.getMovies())
                {
                    listBox1.Items.AddRange(new object[] { m.Title/** + " - " + m.Genre + " - " + m.Time + " - " + m.Description + " - " + m.Price*/ });
                }
            }
        }

        private void listBox2_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {

        }

        private void BookingGUI_Load(object sender, EventArgs e)
        {

        }
    }
}
